package com.example.myprojectoffeixue;

import android.content.Context;
import android.util.Log;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;

/**
 * Created by ASUS on 2016/10/31.
 */
public class MyWebSocketClient extends WebSocketClient {
    public MyWebSocketClient(URI serverUri, Draft draft) {
        super(serverUri, draft);
    }
    @Override
    public void send(String text) {
        Log.d("send",text);
        try {
            text = AESUtil.encrypt(text);
            super.send(text);
        } catch (Exception e) {

        }

    }

    @Override
    public void onOpen(ServerHandshake serverHandshake) {

    }

    @Override
    public void onMessage(String s) {

    }

    @Override
    public void onClose(int i, String s, boolean b) {

    }

    @Override
    public void onError(Exception e) {

    }

    @Override
    public void close() {
        try{
        this.getConnection().close(1000);}
        catch (Exception e){

        }
    }
}
